#include <stdio.h>
#include <iostream>
#include "Use.hpp"
#define ERROR_END "\r\n"
using std::cout;
using std::cerr;
using std::endl;
int main()
{
    string query_string="";
    // cerr<<"will GetQUeryString"<<endl;
    if(GetQUeryString(query_string))
    {
        // LOG(INFO,query_string);
        std::string str1;
        std::string str2;
        std::string name1,name2;
        std::string value1,value2;
        if(CutString(query_string,str1,str2,"&"))
        {
            if(CutString(str1,name1,value1,"=") && CutString(str2,name2,value2,"="))
            {
                int x=std::atoi(value1.c_str());
                int y=std::atoi(value2.c_str());
                    std::cout << "<html>";
                    std::cout << "<head><meta charset=\"utf-8\"></head>";
                    std::cout << "<body>";
                    std::cout << "<h3> " << value1 << " + " << value2 << " = "<< x+y << "</h3>";
                    std::cout << "<h3> " << value1 << " - " << value2 << " = "<< x-y << "</h3>";
                    std::cout << "<h3> " << value1 << " * " << value2 << " = "<< x*y << "</h3>";
                    std::cout << "<h3> " << value1 << " / " << value2 << " = "<< x/y << "</h3>";
                    std::cout << "</body>";
                    std::cout << "</html>";

            }
            else
            {
                LOG(WARENING,"CutString str failed");
            }
        }
        else
        {
                LOG(WARENING,"Request style Error");
        }
        
    }
    else
    {
        string error="";
        error=std::to_string(404);
        error+=ERROR_END;
        cout<<error;
    }
    return 0;
}
